$().ready(function() {
	validateRule();
});


  $.validator.setDefaults({ 
	  submitHandler : function() { 
		  save(); 
	  } 
    });

function save() {
	var formData = new FormData($('#signupForm')[0]);  
	$.ajax({
		cache : false,
		type : "POST",
		url : "/system/company/save",
		data : formData,// 你的formid  
        processData: false,  
        contentType: false,
		error : function(request) {
			parent.layer.alert("文件大小不能超过5M");
		},
		success : function(data) {
			if (data.code == 0) {
				commId = data.msg
				$('#img').fileinput('upload');
				parent.layer.msg("操作成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				parent.layer.alert(data.msg)
			}

		}
	});

}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
			companyName : {
				required : true
			},
			companyType : {
				required : true
			},
			number : {
				required : true
			},
			companyProperty : {
				required : true
			},
			companyStatus : {
				required : true
			},
			representative : {
				required : true
			},
			companyPhone : {
				required : true
			},
			companyEmail : {
				required : true
			},
			companyAdress : {
				required : true
			},
			companyIntroduce : {
				required : true
			},
			file: {
				required : true
			},
		},
		messages : {
			companyName : {
				required : icon + "请输入公司名称"
			},
			companyType : {
				required : icon + "请输入公司类型"
			},
			number : {
				required : icon + "请输入公司人数"
			},
			companyProperty : {
				required : icon + "请输入公司性质"
			},
			companyStatus : {
				required : icon + "请输入公司状态"
			},
			representative : {
				required : icon + "请输入公司法定代表人"
			},
			companyPhone : {
				required : icon + "请输入公司联系电话"
			},
			companyEmail : {
				required : icon + "请输入公司邮箱"
			},
			companyAdress : {
				required : icon + "请输入公司地址"
			},
			companyIntroduce : {
				required : icon + "请输入公司介绍"
			},
			file : {
				required : icon + "请上传图片"
			},
		}
	})
}